<?php

namespace App\Providers;

use App\Http\Middleware\LogRequest;
use Illuminate\Routing\UrlGenerator;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{

    /**
     * All of the container singletons that should be registered.
     *
     * @var array
     */
    public $singletons = [
        //服务
        'link' => 'App\Services\Link',
        'externalService' => 'App\Services\ExternalService',
        'projectService' => 'App\Services\Backend\Activity\ProjectService',
        'roleService' => 'App\Services\Backend\System\RoleService',
        'affairtypeService' => 'App\Services\Backend\System\AffairtypeService',
        'eventtypeService' => 'App\Services\Backend\System\EventtypeService',
        'operationService' => 'App\Services\Backend\System\OperationService',
        'logService' => 'App\Services\Backend\System\LogService',
        'userService' => 'App\Services\Backend\System\UserService',
        'groupService' => 'App\Services\Backend\System\GroupService',
        'dicService' => 'App\Services\Backend\System\DicService',
        'studentService' => 'App\Services\Backend\System\StudentService',

        //仓库
        'projectRepository' => 'App\Repositories\Backend\Activity\ProjectRepository',
        'roleRepository' => 'App\Repositories\Backend\System\RoleRepository',
        'affairtypeRepository' => 'App\Repositories\Backend\System\AffairtypeRepository',
        'eventtypeRepository' => 'App\Repositories\Backend\System\EventtypeRepository',
        'operationRepository' => 'App\Repositories\Backend\System\OperationRepository',
        'termRepository' => 'App\Repositories\Backend\System\TermRepository',
        'logRepository' => 'App\Repositories\Backend\System\LogRepository',
        'groupRepository' => 'App\Repositories\Backend\System\GroupRepository',
        'userRepository' => 'App\Repositories\Backend\System\UserRepository',
        'dicRepository' => 'App\Repositories\Backend\System\DicRepository',
        'dicitemRepository' => 'App\Repositories\Backend\System\DicItemRepository',
        'studentRepository' => 'App\Repositories\Backend\System\StudentRepository',
    ];

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton(LogRequest::class);
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(UrlGenerator $url)
    {
        $protocol = env('APP_PROTOCOL', 'http');
        if($protocol == 'https'){
            //HTTPS
            $url->forceScheme('https'); //这里用https，没有的话自己添加下
        }
    }
}
